package com.rfid.emergencywarehouse.adapter;

import android.view.View;

import androidx.annotation.NonNull;
import androidx.recyclerview.widget.RecyclerView;

import com.rfid.base.base.BaseAdapter;
import com.rfid.emergencywarehouse.R;
import com.rfid.emergencywarehouse.entity.BarcodeInfo;

import java.util.List;

public class PandianAdapter extends MutilChoiceScanBarCodeAdapter {


    public PandianAdapter(List<BarcodeInfo> data) {
        super(data);
    }

    @Override
    protected void bindView(ScanBarcodeAdapter.MyHolder holder, int position, BarcodeInfo t) {
        super.bindView(holder, position, t);
        BarcodeInfo barcodeInfo = mData.get(position);
        holder.model.setText("类型：" + barcodeInfo.getSkuModel());
        holder.name.setText("名称：" + barcodeInfo.getMaterialName());
        if (t.getDiffCount() == -100) {
            holder.pd_resualt.setVisibility(View.GONE);
        } else {
            holder.pd_resualt.setVisibility(View.VISIBLE);
            holder.pd_resualt.setText("盘点结果：" + getPdStr(t.getDiffCount()));
        }
    }

    private String getPdStr(int diffCount) {
        if (diffCount == 0) {
            return "已盘";
        } else if (diffCount == -1) {
            return "盘亏";
        } else if (diffCount == 1) {
            return "盘盈";
        }
        return "";
    }

    @Override
    protected int getLayout() {
        return R.layout.item_pandian;
    }

}
